#!/usr/bin/env python
# -*- encoding: utf-8 -*-
import sys, datetime, os
import pandas as pd


class XDataFrameUtils(object):
    """

    """

    @staticmethod
    def excel2dataframe(p_excel_file_path=None):
        """

        :param p_excel_file_path:
        :return:
        """
        t = p_excel_file_path.lower()
        if t.endswith(".xls"):
            df = pd.DataFrame(pd.read_excel(p_excel_file_path))
        else:
            df = pd.read_excel(p_excel_file_path)
        return df

    @staticmethod
    def dataframe2excel(p_dataframe=None, p_file_name=None, p_override_force=True):
        """

        :param p_dataframe:
        :param p_file_name: like 'abc.xls'
        :param p_override_force:
        :return:
        """
        if p_override_force and os.path.exists(p_file_name):
            os.remove(p_file_name)
        p_dataframe.to_excel(p_file_name)
